/**
 * Modified by Teddy Karam on 2-6-2012 at 4:20 PM.
 *
 */
package com.redteam.data.beans;

import com.redteam.data.enums.MemoState;
import java.io.Serializable;
import java.util.Date;

/**
 * A java bean for Maintenance Memo
 * @author Anthonny Ferrari
 * @author Jeremy Reed
 */
public final class MaintenanceMemo implements Serializable {

    private long ID;
    private String discrepancy;
    private Pilot reporter;
    private Airplane airplane;
    private MaintenanceEngineer mechanic;
    private String notes;
    private MemoState state;
    private Date dateMade;
    private Date dateComplete;
    private static final long serialVersionUID = 1L;



    /**
     *Default constructor
     */
    public MaintenanceMemo() {
        this.setReporter(new Pilot());
        this.setAirplane(new Airplane());
        this.setMechanic(new MaintenanceEngineer());
    }

    /**
     *
     * @param ID
     * @param discrepancy
     * @param reporter
     * @param airplane
     * @param mechanic
     * @param notes
     * @param state
     * @param made
     * @param complete
     */
    public MaintenanceMemo(long ID, String discrepancy, Pilot reporter, Airplane airplane, MaintenanceEngineer mechanic, String notes, String state, Date made, Date complete) {
        this.setID(ID);
        this.setDiscrepancy(discrepancy);
        this.setReporter(reporter);
        this.setAirplane(airplane);
        this.setMechanic(mechanic);
        this.setNotes(notes);
        this.setState(state);
        this.setDateMade(made);
        this.setDateComplete(complete);
    }

    /**
     * Returns the id
     * @return ID
     */
    public long getID() {
        return ID;
    }

    /**
     * Sets the id
     * @param ID
     */
    public void setID(long ID) {
        this.ID = ID;
    }

    /**
     * Returns the airplane associated with the maintenance memo
     * @return airplane
     */
    public Airplane getAirplane() {
        return airplane;
    }

    /**
     * Sets the airplane assigned with the memo
     * @param airplane
     */
    public void setAirplane(Airplane airplane) {
        this.airplane = airplane;
    }

    /**
     * Returns the discrepancy on the memo
     * @return discrepancy
     */
    public String getDiscrepancy() {
        return discrepancy;
    }

    /**
     * Sets the discrepancy
     * @param discrepancy
     */
    public void setDiscrepancy(String discrepancy) {
        this.discrepancy = discrepancy;
    }

    /**
     * Returns the mechanic who the memo has been assigned to
     * @return mechanic
     */
    public MaintenanceEngineer getMechanic() {
        return mechanic;
    }

    /**
     * Sets the mechanic
     * @param mechanic
     */
    public void setMechanic(MaintenanceEngineer mechanic) {
        this.mechanic = mechanic;
    }

    /**
     * Returns the notes on the memo
     * @return notes
     */
    public String getNotes() {
        return notes;
    }

    /**
     * Sets the notes
     * @param notes
     */
    public void setNotes(String notes) {
        this.notes = notes;
    }

    /**
     * Returns the pilot who wrote the memo
     * @return reporter
     */
    public Pilot getReporter() {
        return reporter;
    }

    /**
     * Sets the Pilot who wrote the memo
     * @param reporter
     */
    public final void setReporter(Pilot reporter) {
        this.reporter = reporter;
    }

    /**
     * Returns the current maintenance state
     * @return state
     */
    public String getState() {
        return state.getRepresentation();
    }

    /**
     * Sets the current maintenance state
     * @param state
     */
    public void setState(String state) {
        this.state = MemoState.valueOf(state);
    }

    /**
     * Returns the completion date
     * @return dateComlete
     */
    public Date getDateComplete() {
        return dateComplete;
    }

    /**
     * Set the completion date
     * @param dateComplete
     */
    public void setDateComplete(Date dateComplete) {
        this.dateComplete = dateComplete;
    }

    /**
     * Returns the date the memo was made
     * @return dateMade
     */
    public Date getDateMade() {
        return dateMade;
    }

    /**
     * Sets the date the memo was made
     * @param dateMade
     */
    public void setDateMade(Date dateMade) {
        this.dateMade = dateMade;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final MaintenanceMemo other = (MaintenanceMemo) obj;
        if (this.ID != other.ID) {
            return false;
        }
        if ((this.discrepancy == null) ? (other.discrepancy != null) : !this.discrepancy.equals(other.discrepancy)) {
            return false;
        }
        if (this.reporter != other.reporter && (this.reporter == null || !this.reporter.equals(other.reporter))) {
            return false;
        }
        if (this.airplane != other.airplane && (this.airplane == null || !this.airplane.equals(other.airplane))) {
            return false;
        }
        if (this.mechanic != other.mechanic && (this.mechanic == null || !this.mechanic.equals(other.mechanic))) {
            return false;
        }
        if ((this.notes == null) ? (other.notes != null) : !this.notes.equals(other.notes)) {
            return false;
        }
        if (this.state != other.state) {
            return false;
        }
        if (this.dateMade != other.dateMade && (this.dateMade == null || !this.dateMade.equals(other.dateMade))) {
            return false;
        }
        if (this.dateComplete != other.dateComplete && (this.dateComplete == null || !this.dateComplete.equals(other.dateComplete))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 59 * hash + (int) (this.ID ^ (this.ID >>> 32));
        hash = 59 * hash + (this.discrepancy != null ? this.discrepancy.hashCode() : 0);
        hash = 59 * hash + (this.reporter != null ? this.reporter.hashCode() : 0);
        hash = 59 * hash + (this.airplane != null ? this.airplane.hashCode() : 0);
        hash = 59 * hash + (this.mechanic != null ? this.mechanic.hashCode() : 0);
        hash = 59 * hash + (this.notes != null ? this.notes.hashCode() : 0);
        hash = 59 * hash + (this.state != null ? this.state.hashCode() : 0);
        hash = 59 * hash + (this.dateMade != null ? this.dateMade.hashCode() : 0);
        hash = 59 * hash + (this.dateComplete != null ? this.dateComplete.hashCode() : 0);
        return hash;
    }
}
